﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using MessagePack.Unity;
using MessagePack;
using System.Net.Sockets;
using System;

public class Login {

	GameObject player;

	public void Init () {
//		GameObject.Find ("Canvas/Login").GetComponent<Button> ().onClick.AddListener (OnLogin);
//		MessageProcessor.RegisterWorker(Protocal.register, DecodeMessage);
	}

	void OnLogin() {
//		TestT tc = new TestT ();
//		tc.Id = 1;
//		tc.t = new TestCustom ();
//		tc.t.Id = 45;
//		tc.t.variable = new Vector3 (0, 10, 78);
//		tc.t.v2 = Quaternion.Euler (30, 45, 66);
//
//		byte[] data = MessagePackSerializer.Serialize (tc);
//
//		NetworkManager.Instance.SendDataAsync (data, 0, data.Length, null, null);
	}

	void DecodeMessage(byte[] data) {
//		MsgLoginS2C msg = MessagePackSerializer.Deserialize<MsgLoginS2C> (data);
//
//		if (msg.result) {
//			Debug.LogWarning(msg.Id);
//			Debug.LogWarning(msg.x);
//			Debug.LogWarning(msg.y);
//			Debug.LogWarning(msg.z);
//			player = (GameObject) GameObject.Instantiate (ResourceManager.Instance.GetResource(Config.PlayerPrefabPath));
//			player.transform.position = new Vector3 (msg.x, msg.y, msg.z);
//
//			GameObject.FindGameObjectWithTag ("MainCamera").GetComponent<CameraMovement> ().Target = player.transform;
//		}
	}
}
